//引入实例
import { request1 } from "@/utils/http/index"
//类型
import type {
    cateGory1ListType,
    cateGory2ListType,
    cateGory3ListType,
    attrListParamsType,
    attrListReturnType,
    addOrEditAttrParamsType
} from "@/api/product/model/attrType"


//1.获取一级分类列表
export const requestCategory1List = () => {
    return request1.get<any, cateGory1ListType>(`/admin/product/getCategory1`)
}

//2.获取二级分类列表
export const requestCategory2List = (category1Id: number) => {
    return request1.get<any, cateGory2ListType>(`/admin/product/getCategory2/${category1Id}`)
}

//3.获取三级分类列表
export const requestCategory3List = (category2Id: number) => {
    return request1.get<any, cateGory3ListType>(`/admin/product/getCategory3/${category2Id}`)
}

//4.根据categoryId获取平台属性列表
export const requestAttrList = ({ category1Id, category2Id, category3Id }: attrListParamsType) => {
    return request1.get<any, attrListReturnType>(`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)
}

//5.新增或修改平台属性
export const addOrEditAttr = (payload: addOrEditAttrParamsType) => {
    return request1.post<any, null>(`/admin/product/saveAttrInfo`, payload)
}

//6.删除平台属性
export const deleteAttr = (attrId: number) => {
    return request1.delete<any, null>(`/admin/product/deleteAttr/${attrId}`)
}

